package com.neuedu.nep.controller;

import com.neuedu.nep.base.BaseController;
import com.neuedu.nep.base.R;
import com.neuedu.nep.dto.EditStatisticDTO;
import com.neuedu.nep.model.Statistic;
import com.neuedu.nep.model.Supervisor;
import com.neuedu.nep.service.StatisticService;
import com.neuedu.nep.vo.UserVO;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 黄宇佳
 * @create 2024-04-11 16:07
 * @description:
 */
@RestController
@CrossOrigin
@RequestMapping("statistic")
public class StatisticController extends BaseController {
    @Resource
    private StatisticService statisticService;

    @PutMapping("submitStatistic")
    public R submitStatistic(@RequestBody EditStatisticDTO editStatisticDTO){
        UserVO user = user();
        Integer gmId=user.getGmId();

        Statistic statistic=new Statistic();
        BeanUtils.copyProperties(editStatisticDTO,statistic);
        statistic.setGmId(gmId);
        int result=statisticService.updateStatistic(statistic);
        if (result==2){
            return R.ok();
        }else{
            return R.error();
        }
    }

}
